﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Linq;

namespace SPPD.model
{
    class crud <T>
    {
        private nhibernate nhi;
        public crud()
        {
            nhi = new nhibernate();
        }
        public void insert(T kelas)
        {
            var factory = nhi.CreateSessionFactory();
            using (var session = factory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.Save(kelas);
                }
            }
        }
        public void update(T kelas)
        {
            var factory = nhi.CreateSessionFactory();
            using (var session = factory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var category = kelas;
                    session.Update(kelas);
                    transaction.Commit();
                }
            }

        }
        public ISessionFactory load()
        {
            var factory = nhi.CreateSessionFactory();
            return factory;           
        }
    }
}
